package serverApp.threads;

import java.io.*;

public class WritingThread extends Thread{
	
	private String text, author, date, theme;
	private File fileName;
	private BufferedReader input;
	private BufferedWriter writer;
	
	public WritingThread(String author, String theme, String text, String date){
		this.author = author;
		this.theme = theme;
		this.text = text;
		this.date = date;
	}
	
	public void run(){
		try{
			fileName = new File("/home/devy/123.txt");
			FileWriter fileWriter = new FileWriter(fileName);
			writer = new BufferedWriter(fileWriter);
			writer.write("autor: "+author+"\n");
			writer.write("theme: "+theme+ "\n");
			writer.write("text :"+text+"\n");
			writer.write("date :"+date+"\n");
		}
		catch (IOException exp){
			exp.printStackTrace();
		}
		 finally {
         	if (writer != null){
         		try {
         			writer.close();
         		}
         		catch (IOException exp){
         			exp.printStackTrace();
         		}
         	}
         }

	}
	
}
